﻿<UserControl x:Class="ucUsers"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"             
Width="auto">
    <UserControl.Resources>
        
        <Style x:Key="{x:Type ListBoxItem}" TargetType="{x:Type ListBoxItem}">
            <Setter Property="OverridesDefaultStyle" Value="true" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="Padding" Value="3" />
            <Setter Property="Opacity" Value=".80" />
            <Setter Property="LayoutTransform">
                <Setter.Value>
                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Border Background="{TemplateBinding Background}" 
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Padding="{TemplateBinding Padding}">
                            <ContentPresenter x:Name="ContentSite" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                                            <LinearGradientBrush.GradientStops>
                                                <GradientStop Offset="0" Color="LightGray"/>
                                                <GradientStop Offset="1" Color="DarkGray"/>
                                            </LinearGradientBrush.GradientStops>
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>
                                <Setter Property="BorderBrush" Value="Silver" />
                                <Setter Property="Opacity" Value="1"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true" />
                                    <Condition Property="Selector.IsSelectionActive" 
                                               Value="false" />
                                </MultiTrigger.Conditions>
                                <Setter Property="Background" Value="LightGray" />
                                <Setter Property="BorderBrush" Value="DarkGray" />
                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>            
                <Trigger Property="IsEnabled" Value="false">
                    <Setter Property="Foreground" Value="Gray" />
                </Trigger>
                <EventTrigger RoutedEvent="Mouse.MouseEnter">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <!--DoubleAnimation Duration="0:0:0.0"                                                 
                                                 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleY)"
                                                 From="1" To="1.125"/>
                                    <DoubleAnimation Duration="0:0:0.0"                                                 
                                                 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleX)"
                                                 From="1" To="1.125"/-->
                                <DoubleAnimation Duration="0:0:0.2"
                                                 Storyboard.TargetProperty="Opacity"
                                                 To="1.0" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
                <EventTrigger RoutedEvent="Mouse.MouseLeave">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <!--DoubleAnimation Duration="0:0:0.0"
                                                 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleY)"
                                                 From="1.125" To="1"/>
                                    <DoubleAnimation Duration="0:0:0.0"                                                 
                                                 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleX)"
                                                 From="1.125" To="1"/-->
                                <DoubleAnimation Duration="0:0:0.2"
                                                 Storyboard.TargetProperty="Opacity" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Style.Triggers>
        </Style>

        
        <DataTemplate x:Key="listBoxTemplate">            
            <Border BorderBrush="Blue"
                    BorderThickness="1"
                    CornerRadius="1"
                    Margin="1">                
                <StackPanel Orientation="Horizontal">                               
                    <StackPanel>
                        
                        <TextBlock Text="{Binding Username}" 
                               Foreground="Green" 
                               FontWeight="Bold"
                                   Name="username"/>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Margin="2">Account Locked = </TextBlock >
                            <TextBlock Text="{Binding AccountLocked}" Name="textblockIsLocked"
                                   Margin="2"></TextBlock>

                        </StackPanel>
                    </StackPanel>
                    <Image Source="{Binding lbImageSource}"                           
                           Width="15"
                           Height="15"
                           Margin="10,2,2,2"
                           HorizontalAlignment="Right"
                           Name="userimage"
                           >
                    </Image>
                </StackPanel>
            </Border>
        </DataTemplate>

    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>            
            <ColumnDefinition Width="auto"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>            
        </Grid.ColumnDefinitions>
        <Expander Width="Auto" ExpandDirection="Right" HorizontalAlignment="Right" Grid.Column="0">
            <Expander.Header>
                <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" RenderTransformOrigin="0.5,0.5" Margin="0,0,0,0" Width="Auto" Name="ExpanderText">
            <TextBlock.LayoutTransform>
                <TransformGroup>
                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                    <SkewTransform AngleX="0" AngleY="0"/>
                    <RotateTransform Angle="90"/>
                    <TranslateTransform X="0" Y="0"/>
                </TransformGroup>
            </TextBlock.LayoutTransform>
            <TextBlock.RenderTransform>
                <TransformGroup>
                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                    <SkewTransform AngleX="0" AngleY="0"/>
                    <RotateTransform Angle="0"/>
                    <TranslateTransform X="0" Y="0"/>
                </TransformGroup>
            </TextBlock.RenderTransform>
                </TextBlock>
            </Expander.Header>

            <Border Name="borderHeader" BorderBrush="Gray" 
                BorderThickness="1,1,1,1" 
                                    CornerRadius="6,6,6,6">
            <Grid Name="gridListbox">                
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"></RowDefinition>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                
                <StackPanel Orientation="Horizontal" 
                            Background="Aquamarine"
                            VerticalAlignment="Top"
                            Margin="2" Grid.Row="0">
                    <TextBox MinHeight="10" 
                             MinWidth="126"
                             Margin="2"
                             Name="searchBox"></TextBox>
                    <Button MinWidth="50"                            
                            Margin="2"
                            Name="searchButton">Find</Button>
                </StackPanel>
                <ListBox Name="listBoxUsers"    
                         Grid.Row="1"
                         VerticalAlignment="Top"
                         HorizontalContentAlignment="Stretch"
                         ItemContainerStyle="{DynamicResource ListBoxItem}" 
                         ItemTemplate="{StaticResource listBoxTemplate}" 
                         IsSynchronizedWithCurrentItem="True"
                         ItemsSource="{Binding}"></ListBox>

            </Grid>
        </Border>
            </Expander>
        <Grid Grid.Column="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"></RowDefinition>
                <RowDefinition Height="auto"></RowDefinition>
            </Grid.RowDefinitions>                     
            <Grid Grid.Row="1" Name="gridUserDetails">
                <Grid.Resources>
                    <!--Style x:Key="TextBoxStyle" TargetType="{x:Type TextBox}">
                        <Setter Property="FontSize" Value="14" />
                        <Setter Property="Width" Value="180" />
                        <Setter Property="Height" Value="30" />
                        <Setter Property="VerticalContentAlignment" Value="Center" />
                        <Style.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" Value="pink">
                                                                    </Setter>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="BitmapEffect">
                                    <Setter.Value>                                        
                                        <OuterGlowBitmapEffect GlowColor="Purple" GlowSize="8"/>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="BitmapEffect">
                                    <Setter.Value>
                                        <OuterGlowBitmapEffect GlowColor="Gold" GlowSize="8"/>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                        </Style.Triggers>
                    </Style-->
                </Grid.Resources>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"></RowDefinition>
                    <RowDefinition Height="auto"></RowDefinition>
                    <RowDefinition Height="auto"></RowDefinition>
                    <RowDefinition Height="auto"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"></ColumnDefinition>
                    <ColumnDefinition Width="auto"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Label Grid.Column="0" Grid.Row="0" Margin="5,20,0,0">Username</Label>
                <TextBox Grid.Column="1" Width="250" Margin="5,20,0,0" Grid.Row="0" Name="textboxUser" Style="{DynamicResource TextBoxStyle}"></TextBox>
                <Label Grid.Column="0" Grid.Row="1" Margin="5,5,0,0">Password</Label>
                <PasswordBox  Grid.Column="1" Width="250" Margin="5,5,0,0" Grid.Row="1" Name="passwordboxPassword"></PasswordBox >
                <Label Grid.Column="0" Grid.Row="3" Margin="5,5,0,0" Visibility="Hidden">Password</Label>
                <TextBox Grid.Column="1" Width="250" Margin="5,20,0,0" Grid.Row="3" Name="textboxPassword" Visibility="Hidden"></TextBox>
                <Label Grid.Column="0" Grid.Row="2" Margin="5,5,0,0">Locked</Label>
                <CheckBox Grid.Column="1" Margin="5,5,0,0" Grid.Row="2" Name="cbLocked" VerticalAlignment="Center"></CheckBox>
            </Grid>
        </Grid>
    </Grid>
</UserControl>
